import numpy as np
import librosa
import os
from python_ai.common.xcommon import *

BASE_DIR, FILE_NAME = os.path.split(__file__)
path = '../../../../large_data/audio/_many_files/cat_dog_archive_tidied/cats_dogs/train/dog/dog_barking_0.wav'
audio_path = os.path.join(BASE_DIR, path)

sep('librosa.load')
x, sr = librosa.load(audio_path, res_type='kaiser_fast', sr=None)
# print('x', x)
print_numpy_ndarray_info(x, 'x')  # (275203, )
print('sr', sr)

sep('mfcc')
mfcc = librosa.feature.mfcc(x, sr=sr, n_mfcc=100)  # ATTENTION: frame: 2048, shift: 512
# print('mfcc', mfcc)
print_numpy_ndarray_info(mfcc, 'mfcc')
print((275203 - 2048) / 512)
